package sample.enums;

import com.alibaba.fastjson.JSONObject;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public enum  MapExecCode {

    COMPLETE(200, "执行完成"),
    NODATA(300, "无数据"),
    STOP(301, "停止执行"),
    QUOTA_NOT_ENOUGH(401, "当前并发量已经超过约定并发配额，限制访问");

    private Integer code;

    private String desc;

    public static final Map<Integer, String> map = Stream.of(values()).collect(Collectors.toMap(MapExecCode::getCode, MapExecCode::getDesc));

    MapExecCode(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }
}
